﻿
Partial Class UserControls_Modal
    Inherits System.Web.UI.UserControl
    Implements INamingContainer

    Private _boxTemplate As ITemplate = Nothing
    <TemplateContainer(GetType(UserControls_Modal)), _
    PersistenceMode(PersistenceMode.InnerProperty), _
    TemplateInstance(TemplateInstance.Single)> _
    Public Property BoxTemplate() As ITemplate
        Get
            Return _boxTemplate
        End Get
        Set(ByVal value As ITemplate)
            _boxTemplate = value
        End Set
    End Property

    Public ReadOnly Property ModalClientID() As String
        Get
            Return m.ClientID
        End Get
    End Property

    Public Property X() As Integer
        Get
            Return m.X
        End Get
        Set(ByVal value As Integer)
            m.X = value
        End Set
    End Property

    Public Property Y() As Integer
        Get
            Return m.Y
        End Get
        Set(ByVal value As Integer)
            m.Y = value
        End Set
    End Property

    Public Property EnablePositionEdit() As Boolean
        Get
            If PnlEditParam IsNot Nothing Then
                Return PnlEditParam.Visible
            Else
                Return False
            End If
        End Get
        Set(ByVal value As Boolean)
            If PnlEditParam IsNot Nothing Then
                PnlEditParam.Visible = value
            End If
        End Set
    End Property

    Public Property Titulo() As String
        Get
            Return lblTitulo.Text
        End Get
        Set(ByVal value As String)
            lblTitulo.Text = value
        End Set
    End Property

    Private _height As Integer
    Public Property Height() As Unit
        Get
            Return PanelScroll.Height
        End Get
        Set(ByVal value As Unit)
            PanelScroll.Height = value
            'pnlDetalheModalPopup.Height = value.Value
        End Set
    End Property

    Public Property Width() As Unit
        Get
            Return PanelScroll.Width
        End Get
        Set(ByVal value As Unit)
            PanelScroll.Width = value
            'pnlDetalheModalPopup.Width = value.Value + 10
        End Set
    End Property

    Public Property RepositionMode() As AjaxControlToolkit.ModalPopupRepositionMode
        Get
            Return m.RepositionMode
        End Get
        Set(ByVal value As AjaxControlToolkit.ModalPopupRepositionMode)
            m.RepositionMode = value
        End Set
    End Property


    Public Sub Show()
        Me.m.Show()
    End Sub

    Public Sub Hide()
        Me.m.Hide()
    End Sub

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

        If Me.BoxTemplate IsNot Nothing Then
            Dim container As New UserControls_Modal()
            BoxTemplate.InstantiateIn(container)
            plcHldContent.Controls.Add(container)
        End If

    End Sub


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then
            Me.DataBindParametrizacao()
        End If

    End Sub

#Region "Operacoes do Usuário"

    Protected Sub BtnAtualiza_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnAtualiza.Click

        Me.Y = CInt(TxtY.Text)
        Me.Height = CDbl(TxtHeight.Text)
        Me.Width = CDbl(TxtWidth.Text)

    End Sub

#End Region

#Region "Funcoes DataBind"

    Protected Sub DataBindParametrizacao()

        If Me.EnablePositionEdit Then
            TxtY.Text = Me.Y
            TxtHeight.Text = Me.Height.Value
            TxtWidth.Text = Me.Width.Value
        End If

    End Sub

#End Region



End Class
